// pages/project/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isDetail:false,
    index:null,
    dataArray: [
      {
        "title": "书签管理系统",
        "sub-title":"JWT+MEAN",
        "imgSrc": "/images/projects/bookmarks.jpg",
        "project-href1": "https://github.com/Caibiy/DomainManager",
        "project_href2": "https://www.youtube.com/channel/UC29ju8bIPH5as8OGnQzwJyA",
        "project-intro": "项目使用Express作为后端，MongoDB作为数据库,Passport作为信息验证,Angular2作为信息展示，项目学习与Youtube博主。Traversy Media"
      },
      {
        "title": "吃金子",
        "imgSrc": "/images/projects/gold.png",
        "sub-title": "processing吃金子小游戏",
        "project-href1": "https://github.com/Caibiy/Golden_Miner_revised_Start_Over_Time",
        "project-intro": "项目使用了processing作为开发语言(类似Java的语法),集成了sound动画库"
      },
      {
        "title":"树莓派浇花系统",
        "imgSrc":"/images/projects/jiaohua.png",
        "sub-title": "基于Raspberrypi",
        "project-href1": "https://github.com/Caibiy/Raspberrypi_flowers",
        "project-intro": "基于Raspberrypi作为平台,使用到了Express、ECharts、BootStrap、Mjpg-streamer、MongoDB、以及相关的一些读取传感器的脚本库"
      }
    ]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this._Initialize()
  },
  onDetail: function(event){
    const index = event.currentTarget.dataset.index
    this.setData({
      isDetail:true,
      index
    })
  },
  onCopy(event){
    let that = this;
    wx.setClipboardData({
      data: that.data.dataArray[that.data.index]['project-href1'],
      success: function (res) {
        wx.getClipboardData({
          success: function (res) {
            wx.showToast({
              title: '链接已复制',
              image: '/images/icon/link.png',
              duration: 1000
            })
          }
        })
      }
    })
  },
  _Initialize(){
    this.setData({
      index: null,
      isDetail:false
    })
  },
  onBack(event){
    this._Initialize();
  }
})